﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace StoreWeb.ajax
{
    public partial class autocomplete : System.Web.UI.Page
    {
        Maticsoft.BLL.Inventory dbll = new Maticsoft.BLL.Inventory();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request["id"]))
                {
                    Response.Write((dbll.GetModelList("cInvCode='" + Request["id"] + "'").Count > 0 ? "1" : "0"));
                }
                else
                {
                    Response.Write(JsonConvert.SerializeObject(dbll.GetModelList("ptype<>1").Select(c => new { cInvCode = c.cInvCode, cInvName = c.cInvName }).ToList()));
                }
            }
        }
    }
}